package com.worldcup.conf;

import com.worldcup.conf.filter.CorsFilter;
import com.worldcup.conf.filter.RequestLoggingFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author duwan.zq
 * @date 2018/06/02
 */
@Configuration
public class FilterConfig {

    //@Bean
    //public FilterRegistrationBean loggingFilter() {
    //    RequestLoggingFilter loggingFilter = new RequestLoggingFilter();
    //    FilterRegistrationBean registration = new FilterRegistrationBean(loggingFilter);
    //    registration.setEnabled(true);
    //    return registration;
    //}


    @Bean
    public FilterRegistrationBean corsFilter() {
        CorsFilter corsFilter = new CorsFilter();
        FilterRegistrationBean registration = new FilterRegistrationBean(corsFilter);
        registration.setEnabled(true);
        return registration;
    }
}
